import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:imember/UI/Stock/HistoryRecord.dart';
import 'package:imember/UI/Stock/StockAdjust.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Util/PageUtil.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyImage.dart';
import 'package:imember/Widget/MyInput.dart';
import 'package:imember/Widget/MyPage.dart';

import 'StockTake.dart';

class StockManager extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return StockManagerState();
  }
}

class StockManagerState extends State {
  @override
  Widget build(BuildContext context) {
    return MyPage(
        Container(
            alignment: Alignment.topCenter,
            margin: EdgeInsets.only(top: 25),
            child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
              ItemBox("ic_summary_history_record.png", "進貨盤點", onTap: () {
                PageUtil().open(context, StockTake(StockTake.Purchases));
              }),
              ItemBox("ic_summary_history_record.png", "庫存盤點", onTap: () {
                PageUtil().open(context, StockTake(StockTake.Stock));
              }),
              ItemBox("ic_summary_history_record.png", "盤點調整", onTap: () {
                PageUtil().open(context, StockAdjust());
              }),
              ItemBox("ic_summary_history_record.png", "歷史紀錄", onTap: () {
                PageUtil().open(context, HistoryRecord());
              }),
            ])),
        showIcon: true,
        showNotice: true);
  }
}

class ItemBox extends StatelessWidget {
  String icon;
  String title;
  Function() onTap;

  ItemBox(this.icon, this.title, {required this.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
          width: 174,
          height: 145,
          margin: EdgeInsets.all(25),
          decoration: Global.getBoxBg(16, MyColor.Orange2),
          child: Stack(alignment: Alignment.bottomCenter, children: [
            Positioned(top: 16, left: 16, child: LocalImage(icon, width: 50)),
            Container(
              margin: EdgeInsets.only(bottom: 16),
              child: Text(title, style: TextStyle(fontSize: 24, color: MyColor.White, fontWeight: FontWeight.bold)),
            )
          ])),
    );
  }
}
